package practise.alogrithm.gotoSiliconValley.array;

/**
 * Created by xinlyu on 8/4/2014.
 */
public class CheckPairableElementDevideByExpectNumber {
    public boolean checkPairable(int[] values, int expect){
        int[] counts = new int[expect];
        for(int value : values){
            counts[value%expect]++;
        }
        if(counts[0]%2!=0)return false;
        if(expect%2==0&&counts[expect/2]%2!=0)return false;
        for(int index=1;index<=counts.length/2;index++){
            if(counts[index]!=counts[expect-index])return false;
        }
        return true;
    }
}
